home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kmdimainfrm.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-03-17  |  28.6 KB  |  880 lines

  1. //----------------------------------------------------------------------------
  2. //    filename             : kmdimainfrm.h
  3. //----------------------------------------------------------------------------
  4. //    Project              : KDE MDI extension
  5. //
  6. //    begin                : 07/1999       by Szymon Stefanek as part of kvirc
  7. //                                         (an IRC application)
  8. //    changes              : 09/1999       by Falk Brettschneider to create an
  9. //                           - 06/2000     stand-alone Qt extension set of
  10. //                                         classes and a Qt-based library
  11. //                         : 02/2000       by Massimo Morin (mmorin@schedsys.com)
  12. //                           2000-2003     maintained by the KDevelop project
  13. //    patches              : */2000        by Lars Beikirch (Lars.Beikirch@gmx.net)
  14. //                         : 01/2003       by Jens Zurheide (jens.zurheide@gmx.de)
  15. //
  16. //    copyright            : (C) 1999-2003 by Falk Brettschneider
  17. //                                         and
  18. //                                         Szymon Stefanek (stefanek@tin.it)
  19. //    email                :  falkbr@kdevelop.org (Falk Brettschneider)
  20. //----------------------------------------------------------------------------
  21. //
  22. //----------------------------------------------------------------------------
  23. //
  24. //    This program is free software; you can redistribute it and/or modify
  25. //    it under the terms of the GNU Library General Public License as
  26. //    published by the Free Software Foundation; either version 2 of the
  27. //    License, or (at your option) any later version.
  28. //
  29. //----------------------------------------------------------------------------
  30.  
  31. #ifndef _KMDIMAINFRM_H_
  32. #define _KMDIMAINFRM_H_
  33.  
  34. #include <kparts/dockmainwindow.h>
  35. #include <kmenubar.h>
  36. #include <kpopupmenu.h>
  37.  
  38. #include <qptrlist.h>
  39. #include <qrect.h>
  40. #include <qapplication.h>
  41. #include <qdom.h>
  42. #include <qguardedptr.h>
  43.  
  44. #include "kmditaskbar.h"
  45. #include "kmdichildarea.h"
  46. #include "kmdichildview.h"
  47. #include "kmdiiterator.h"
  48. #include "kmdilistiterator.h"
  49. #include "kmdinulliterator.h"
  50. #include "kmditoolviewaccessor.h"
  51.  
  52. class QTimer;
  53. class QPopupMenu;
  54. class QMenuBar;
  55.  
  56.  
  57. class QToolButton;
  58.  
  59. namespace KMDIPrivate
  60. {
  61. class KMDIGUIClient;
  62. }
  63.  
  64. class KMdiDockContainer;
  65. class KMdiMainFrmPrivate;
  66.  
  67. /**
  68.  * @short Internal class
  69.  *
  70.  * This special event is needed because the view has to inform the main frame that it`s being closed.
  71.  */
  72. class KMDI_EXPORT KMdiViewCloseEvent : public QCustomEvent
  73. {
  74. public:
  75.     KMdiViewCloseEvent( KMdiChildView* pWnd ) : QCustomEvent( QEvent::User, pWnd ) {}
  76. };
  77.  
  78. /**
  79.  * \short Base class for all your special main frames.
  80.  *
  81.  * It contains the child frame area (QMainWindow's central widget) and a child view taskbar
  82.  * for switching the MDI views. Most methods are virtual functions for later overriding.
  83.  *
  84.  * Basically, this class provides functionality for docking/undocking view windows and
  85.  * manages the taskbar. Usually a developer will only need to know about this class and
  86.  * \ref KMdiChildView.
  87.  *
  88.  * \par General usage
  89.  *
  90.  * Your program mainwidget should inherit KMdiMainFrm. Then usually you'll just need
  91.  * addWindow() and removeWindowFromMdi() to control the views.
  92.  * \code
  93.  *        class MyMainWindow : public KMdiMainFrm
  94.  *        { .... };
  95.  * \endcode
  96.  *
  97.  * to define your main window class and
  98.  *
  99.  * \code
  100.  *        MyMainWindow mainframe;
  101.  *        qApp->setMainWidget(&mainframe);
  102.  *        mainframe->addWindow(view1); // put it under MDI control
  103.  *        mainframe->addWindow(view2);
  104.  * \endcode
  105.  *
  106.  * when you wish to use your main window class. The above example also adds a few windows
  107.  * to the frame.
  108.  *
  109.  * KMdiMainFrm will provide the "Window" menu needed in common MDI applications. Just
  110.  * insert it in your main menu:
  111.  *
  112.  * \code
  113.  *         if ( !isFakingSDIApplication() )
  114.  *         {
  115.  *             menuBar()->insertItem( i18n( "&Window" ), windowMenu() );
  116.  *         }
  117.  * \endcode
  118.  *
  119.  * To synchronize the positions of the MDI control buttons inserted in your mainmenu:
  120.  * \code
  121.  *         void B_MainModuleWidget::initMenuBar()
  122.  *         {
  123.  *             setMenuForSDIModeSysButtons( menuBar() );
  124.  *         }
  125.  *         ...
  126.  *        void B_MainModuleWidget::resizeEvent ( QResizeEvent *e )
  127.  *        {
  128.  *            KMdiMainFrm::resizeEvent( e );
  129.  *            setSysButtonsAtMenuPosition();
  130.  *        }
  131.  * \endcode
  132.  *
  133.  * \par Dynamic mode switching
  134.  *
  135.  * Dynamic switching of the MDI mode can be done via the following functions:
  136.  * - switchToChildframeMode()
  137.  * - switchToToplevelMode()
  138.  * - switchToTabPageMode()
  139.  * - switchToIDEAlMode()
  140.  *
  141.  * The MDI mode can be gotten using mdiMode(). If you need to fake the look of an SDI application
  142.  * use fakeSDIApplication() to fake it and isFakingSDIApplication() to query whether or not an SDI
  143.  * interface is being faked.
  144.  *
  145.  * You can dynamically change the shape of the attached MDI views using setFrameDecorOfAttachedViews().
  146.  *
  147.  * Additionally, here's a hint how to restore the mainframe's settings from config file:
  148.  * \code
  149.  *
  150.  *    // restore MDI mode (toplevel, childframe, tabpage)
  151.  *    int mdiMode = config->readIntEntry( "mainmodule session", "MDI mode", KMdi::ChildframeMode);
  152.  *    switch (mdiMode) {
  153.  *    case KMdi::ToplevelMode:
  154.  *       {
  155.  *          int childFrmModeHt = config->readIntEntry( "mainmodule session", "Childframe mode height", desktop()->height() - 50);
  156.  *          mainframe->resize( m_pMdiMainFrm->width(), childFrmModeHt);
  157.  *          mainframe->switchToToplevelMode();
  158.  *       }
  159.  *       break;
  160.  *    case KMdi::ChildframeMode:
  161.  *       break;
  162.  *    case KMdi::TabPageMode:
  163.  *       {
  164.  *          int childFrmModeHt = m_pCfgFileManager->readIntEntry( "mainmodule session", "Childframe mode height", desktop()->height() - 50);
  165.  *          mainframe->resize( m_pMdiMainFrm->width(), childFrmModeHt);
  166.  *          mainframe->switchToTabPageMode();
  167.  *       }
  168.  *       break;
  169.  *    default:
  170.  *       break;
  171.  *    }
  172.  *
  173.  *    // restore a possible maximized Childframe mode
  174.  *    bool maxChildFrmMode = config->readBoolEntry( "mainmodule session", "maximized childframes", true);
  175.  *    mainframe->setEnableMaximizedChildFrmMode(maxChildFrmMode);
  176.  * \endcode
  177.  * The maximized-Childframe mode means that currently all views are maximized in Childframe mode's application desktop.
  178.  *
  179.  * \par Managing views
  180.  *
  181.  * This class provides placing algorithms in Childframe mode. The following is a list of the window placement functions
  182.  * - tilePragma() - Tile the windows and allow them to overlap
  183.  * - tileAnodine() - Tile the windows but don't allow them to overlap
  184.  * - tileVertically() - Tile the windows vertically
  185.  * - cascadeWindows() - cascade windows
  186.  * - cascadeMaximized() - cascade windows and maximize their viewing area
  187.  * - expandVertical() - expand all the windows to use the most amount of vertical space
  188.  * - expandHorizontal() - expand all the windows to use the most amount of horizontal space
  189.  *
  190.  * activateView(KMdiChildView*) and activateView(int index) set the appropriate MDI child view as the active
  191.  * one. It will be raised, will get an active MDI frame and will get the focus. Call activeView() to find out what the
  192.  * current MDI view is.
  193.  *
  194.  * Use detachWindow() and attachWindow() for docking the MDI views to desktop and back.
  195.  *
  196.  * Connect accels of your program with activatePrevWin(), activateNextWin() and activateView(int index).
  197.  *
  198.  * Note: KMdiChildViews can be added in 2 meanings: Either as a normal child view (usually containing
  199.  * user document views) or as a tool-view (usually containing status, info or control widgets).
  200.  * The tool-views can be added as floating dockwidgets or as stay-on-top desktop windows in tool style.
  201.  *
  202.  * Also, pay attention to the fact that when you click on the close button of MDI views that their
  203.  * close event should be redirected to closeWindow(). Otherwise the mainframe class will
  204.  * not get noticed about the deleted view and a dangling pointer will remain in the MDI control. The
  205.  * closeWindow() or the removeWindowFromMdi() method is for that issue. The difference is closeWindow()
  206.  * deletes the view object. So if your application wants to control that by itself, call removeWindowFromMdi()
  207.  * and call delete by yourself. See also KMdiChildView::closeEvent() for that issue.
  208.  *
  209.  * Here's an example how you can suggest things for the adding of views to the MDI control via flags:
  210.  * \code
  211.  *        m_mapOfMdiWidgets.insert( pWnd, mh );
  212.  *        unsigned int mdiFlags = KMdi::StandardAdd;
  213.  *
  214.  *         if ( !show )
  215.  *            mdiFlags |= KMdi::Hide;
  216.  *
  217.  *         if ( !attach )
  218.  *            mdiFlags |= KMdi::Detach;
  219.  *
  220.  *         if ( minimize )
  221.  *            mdiFlags |= KMdi::Minimize;
  222.  *
  223.  *         if ( bToolWindow)
  224.  *            mdiFlags |= KMdi::ToolWindow;
  225.  *
  226.  *        if ( m_pMdiMainFrm->isFakingSDIApplication() )
  227.  *        {
  228.  *            if ( attach ) //fake an SDI app
  229.  *                mdiFlags |= KMdi::Maximize;
  230.  *        }
  231.  *        else
  232.  *        {
  233.  *            m_pMdiMainFrm->addWindow( pWnd, QPoint(20, 20), KMdi::AddWindowFlags(mdiFlags));
  234.  *            return;
  235.  *        }
  236.  *        m_pMdiMainFrm->addWindow( pWnd, KMdi::AddWindowFlags(mdiFlags));
  237.  * \endcode
  238.  */
  239. class KMDI_EXPORT KMdiMainFrm : public KParts::DockMainWindow
  240. {
  241.     friend class KMdiChildView;
  242.     friend class KMdiTaskBar;
  243.     Q_OBJECT
  244.  
  245.     friend class KMdiToolViewAccessor;
  246.     // attributes
  247. protected:
  248.     KMdi::MdiMode m_mdiMode;
  249.     KMdiChildArea *m_pMdi;
  250.     KMdiTaskBar *m_pTaskBar;
  251.     QPtrList<KMdiChildView> *m_pDocumentViews;
  252.     QMap<QWidget*, KMdiToolViewAccessor*> *m_pToolViews;
  253.     KMdiChildView *m_pCurrentWindow;
  254.     QPopupMenu *m_pWindowPopup;
  255.     QPopupMenu *m_pTaskBarPopup;
  256.     QPopupMenu *m_pWindowMenu;
  257.     QPopupMenu *m_pDockMenu;
  258.     QPopupMenu *m_pMdiModeMenu;
  259.     QPopupMenu *m_pPlacingMenu;
  260.     KMenuBar *m_pMainMenuBar;
  261.  
  262.     QPixmap *m_pUndockButtonPixmap;
  263.     QPixmap *m_pMinButtonPixmap;
  264.     QPixmap *m_pRestoreButtonPixmap;
  265.     QPixmap *m_pCloseButtonPixmap;
  266.  
  267.     QToolButton *m_pUndock;
  268.     QToolButton *m_pMinimize;
  269.     QToolButton *m_pRestore;
  270.     QToolButton *m_pClose;
  271.     QPoint m_undockPositioningOffset;
  272.     bool m_bMaximizedChildFrmMode;
  273.     int m_oldMainFrmHeight;
  274.     int m_oldMainFrmMinHeight;
  275.     int m_oldMainFrmMaxHeight;
  276.     static KMdi::FrameDecor m_frameDecoration;
  277.     bool m_bSDIApplication;
  278.     KDockWidget* m_pDockbaseAreaOfDocumentViews;
  279.     QDomDocument* m_pTempDockSession;
  280.     bool m_bClearingOfWindowMenuBlocked;
  281.  
  282.     QTimer* m_pDragEndTimer;
  283.  
  284.     bool m_bSwitching;
  285.  
  286.     KDockWidget* m_leftContainer;
  287.     KDockWidget* m_rightContainer;
  288.     KDockWidget* m_topContainer;
  289.     KDockWidget* m_bottomContainer;
  290.  
  291.  
  292. private:
  293.     KMdiMainFrmPrivate* d;
  294.     KMDIPrivate::KMDIGUIClient* m_mdiGUIClient;
  295.     bool m_managedDockPositionMode;
  296.  
  297.     // methods
  298. public:
  299.     KMdiMainFrm( QWidget* parentWidget, const char* name = "", KMdi::MdiMode mdiMode = KMdi::ChildframeMode, WFlags flags = WType_TopLevel | WDestructiveClose );
  300.     virtual ~KMdiMainFrm();
  301.  
  302.     /**
  303.      * Control whether or not the standard MDI menu is displayed
  304.      * when a context menu is displayed
  305.      */
  306.     void setStandardMDIMenuEnabled( bool showModeMenu = true );
  307.  
  308.     void setManagedDockPositionModeEnabled( bool enabled );
  309.  
  310.     /**
  311.      * Returns whether the application's MDI views are in maximized state or not.
  312.      */
  313.     bool isInMaximizedChildFrmMode() { return m_bMaximizedChildFrmMode; }
  314.  
  315.     /**
  316.      * Returns the MDI mode. This can be one of the enumerations KMdi::MdiMode.
  317.      */
  318.     KMdi::MdiMode mdiMode() { return m_mdiMode; }
  319.  
  320.     /**
  321.      * Returns the focused attached MDI view.
  322.      */
  323.     KMdiChildView* activeWindow();
  324.  
  325.     /**
  326.      * Returns a popup menu filled according to the MDI view state. You can override this
  327.      * method to insert additional entries there. The popup menu is usually popuped when the user
  328.      * clicks with the right mouse button on a taskbar entry. The default entries are:
  329.      * Undock/Dock, Restore/Maximize/Minimize, Close and an empty sub-popup ( windowPopup() )
  330.      * menu called Operations.
  331.      */
  332.     virtual QPopupMenu * taskBarPopup( KMdiChildView *pWnd, bool bIncludeWindowPopup = false );
  333.  
  334.     /**
  335.      * Returns a popup menu with only a title "Window". You can fill it with own operations entries
  336.      * on the MDI view. This popup menu is inserted as last menu item in taskBarPopup() .
  337.      */
  338.     virtual QPopupMenu * windowPopup( KMdiChildView *pWnd, bool bIncludeTaskbarPopup = true );
  339.  
  340.     /**
  341.      * Called in the constructor (forces a resize of all MDI views)
  342.      */
  343.     virtual void applyOptions();
  344.  
  345.     /**
  346.      * Returns the KMdiChildView belonging to the given caption string.
  347.      */
  348.     KMdiChildView * findWindow( const QString& caption );
  349.  
  350.     enum ExistsAs {DocumentView, ToolView, AnyView};
  351.     /**
  352.      * Returns whether this MDI child view is under MDI control (using addWindow() ) or not.
  353.      */
  354.     bool windowExists( KMdiChildView *pWnd, ExistsAs as );
  355.  
  356.     /**
  357.      * Catches certain Qt events and processes it here.
  358.      * Currently, here this catches only the KMdiViewCloseEvent (a KMdi user event) which is sent
  359.      * from itself in childWindowCloseRequest() right after a KMdiChildView::closeEvent() .
  360.      * The reason for this event to itself is simple: It just wants to break the function call stack.
  361.      * It continues the processing with calling closeWindow() .
  362.      * You see, a close() is translated to a closeWindow() .
  363.      * It is necessary that the main frame has to start an MDI view close action because it must
  364.      * remove the MDI view from MDI control, additionally.
  365.      *
  366.      * This method calls QMainWindow::event , additionally.
  367.      */
  368.     virtual bool event( QEvent* e );
  369.  
  370.     /**
  371.      * If there's a main menubar given, it will create the 4 maximize mode buttons there (undock, minimize, restore, close).
  372.      */
  373.     virtual void setSysButtonsAtMenuPosition();
  374.  
  375.     /**
  376.      * Returns the height of the taskbar.
  377.      */
  378.     virtual int taskBarHeight() { return m_pTaskBar ? m_pTaskBar->height() : 0; }
  379.  
  380.     /**
  381.      * Sets an offset value that is used on detachWindow() . The undocked window
  382.      * is visually moved on the desktop by this offset.
  383.      */
  384.     virtual void setUndockPositioningOffset( QPoint offset ) { m_undockPositioningOffset = offset; }
  385.  
  386.     /**
  387.      * If you don't want to know about the inner structure of the KMdi system, you can use
  388.      * this iterator to handle with the MDI view list in a more abstract way.
  389.      * The iterator hides what special data structure is used in KMdi.
  390.      * The caller must delete the iterator once he does not need it anymore.    
  391.      */
  392.     // FIXME And what exactly are we supposed to fix? -mattr
  393.     KMdiIterator<KMdiChildView*>* createIterator()
  394.     {
  395.         if ( m_pDocumentViews == 0L )
  396.         {
  397.             return new KMdiNullIterator<KMdiChildView*>();
  398.         }
  399.         else
  400.         {
  401.             return new KMdiListIterator<KMdiChildView>( *m_pDocumentViews );
  402.         }
  403.     }
  404.  
  405.     /**
  406.      * Deletes an KMdiIterator created in the KMdi library (needed for the windows dll problem).
  407.      */
  408.     void deleteIterator( KMdiIterator<KMdiChildView*>* pIt )
  409.     {
  410.         delete pIt;
  411.     }
  412.  
  413.     /**
  414.      * Returns a popup menu that contains the MDI controlled view list.
  415.      * Additionally, this menu provides some placing actions for these views.
  416.      * Usually, you insert this popup menu in your main menubar as "Window" menu.
  417.      */
  418.     QPopupMenu* windowMenu() const  { return m_pWindowMenu; };
  419.  
  420.     /**
  421.      * Sets a background color for the MDI view area widget.
  422.      */
  423.     virtual void setBackgroundColor( const QColor &c ) { m_pMdi->setBackgroundColor( c ); }
  424.  
  425.     /**
  426.      * Sets a background pixmap for the MDI view area widget.
  427.      */
  428.     virtual void setBackgroundPixmap( const QPixmap &pm ) { m_pMdi->setBackgroundPixmap( pm ); }
  429.  
  430.     /**
  431.      * Sets a size that is used as the default size for a newly to the MDI system added KMdiChildView .
  432.      *  By default this size is 600x400. So all non-resized added MDI views appear in that size.
  433.      */
  434.     void setDefaultChildFrmSize( const QSize& sz ) { m_pMdi->m_defaultChildFrmSize = sz; }
  435.  
  436.     /**
  437.      * Returns the default size for a newly added KMdiChildView. See setDefaultChildFrmSize() .
  438.      */
  439.     QSize defaultChildFrmSize() { return m_pMdi->m_defaultChildFrmSize; }
  440.  
  441.     /**
  442.      * Do nothing when in Toplevel mode
  443.      */
  444.     virtual void setMinimumSize( int minw, int minh );
  445.  
  446.     /**
  447.      * Returns the Childframe mode height of this. Makes only sense when in Toplevel mode.
  448.      */
  449.     int childFrameModeHeight() { return m_oldMainFrmHeight; };
  450.     /**
  451.      * Tells the MDI system a QMenu where it can insert buttons for
  452.      * the system menu, undock, minimize, restore actions.
  453.      * If no such menu is given, KMdi simply overlays the buttons
  454.      * at the upper right-hand side of the main widget.
  455.      */
  456.     virtual void setMenuForSDIModeSysButtons( KMenuBar* menuBar = 0 );
  457.  
  458.     /**
  459.      * @return the decoration of the window frame of docked (attached) MDI views
  460.      */
  461.     static int frameDecorOfAttachedViews() { return m_frameDecoration; }
  462.  
  463.     /**
  464.      * An SDI application user interface is faked:
  465.      * @li an opened view is always maximized
  466.      * @li buttons for maximized childframe mode aren't inserted in the main menubar
  467.      * @li taskbar and windowmenu are not created/updated
  468.      */
  469.     void fakeSDIApplication();
  470.  
  471.     /**
  472.      * @returns if we are faking an SDI application (fakeSDIApplication())
  473.      */
  474.     bool isFakingSDIApplication() const { return m_bSDIApplication; }
  475.  
  476.     virtual bool eventFilter( QObject *obj, QEvent *e );
  477.     void findRootDockWidgets( QPtrList<KDockWidget>* pRootDockWidgetList, QValueList<QRect>* pPositionList );
  478.  
  479.     /** We're switching something.*/
  480.     void setSwitching( const bool switching ) { m_bSwitching = switching; }
  481.     bool switching( void ) const { return m_bSwitching; }
  482.  
  483. public slots:
  484.     /**
  485.      * addWindow demands a KMdiChildView. This method wraps every QWidget in such an object and
  486.      * this way you can put every widget under MDI control.
  487.      */
  488.     KMdiChildView* createWrapper( QWidget *view, const QString& name, const QString& shortName );
  489.  
  490.     /**
  491.      * Adds a KMdiChildView to the MDI system. The main frame takes control of it.
  492.      * \param pWnd the parent view.
  493.      * \param flags the flags for the view such as:
  494.      * \li whether the view should be attached or detached.
  495.      * \li whether the view should be shown or hidden
  496.      * \li whether the view should be maximized, minimized or restored (normalized)
  497.      * \li whether the view should be added as tool view (stay-on-top and toplevel) or added as document-type view.
  498.      */
  499.     virtual void addWindow( KMdiChildView* pWnd, int flags = KMdi::StandardAdd );
  500.  
  501.     //KDE4: merge the two methods
  502.     /**
  503.      * Adds a KMdiChildView to the MDI system. The main frame takes control of it.
  504.      * \param pWnd the parent view.
  505.      * \param flags
  506.      * You can specify here whether:
  507.      * \li the view should be attached or detached.
  508.      * \li shown or hidden
  509.      * \li maximized, minimized or restored (normalized)
  510.      * \li added as tool view (stay-on-top and toplevel) or added as
  511.      * document-type view.
  512.      * \param index the index of the tab we should insert the new tab after.
  513.      * If index == -1 then the tab will just be appended to the end.
  514.      * Using this parameter in childview mode has no effect.
  515.      * \since 3.3
  516.      */
  517.     void addWindow( KMdiChildView* pWnd, int flags, int index );
  518.  
  519.     /**
  520.      * Adds a KMdiChildView to the MDI system. The main frame takes control of it.
  521.      * \param pWnd the parent view.
  522.      * \param pos move the child view to the specified position
  523.      * \param flags the flags for the view such as:
  524.      * \li whether the view should be attached or detached.
  525.      * \li whether the view should be shown or hidden
  526.      * \li whether the view should be maximized, minimized or restored (normalized)
  527.      * \li whether the view should be added as tool view (stay-on-top and toplevel) or
  528.      * added as document-type view.
  529.      */
  530.     virtual void addWindow( KMdiChildView* pWnd, QPoint pos, int flags = KMdi::StandardAdd );
  531.  
  532.     /**
  533.      * Adds a KMdiChildView to the MDI system. The main frame takes control of it.
  534.      * \param pWnd the parent view.
  535.      * \param rectNormal Sets the geometry for this child view
  536.      * \param flags the flags for the view such as:
  537.      * \li whether the view should be attached or detached.
  538.      * \li whether the view should be shown or hidden
  539.      * \li whether the view should be maximized, minimized or restored (normalized)
  540.      * \li whether the view should be added as tool view (stay-on-top and toplevel) or
  541.      * added as document-type view.
  542.      */
  543.     virtual void addWindow( KMdiChildView* pWnd, QRect rectNormal, int flags = KMdi::StandardAdd );
  544.  
  545.     /**
  546.      * Usually called from addWindow() when adding a tool view window. It reparents the given widget
  547.      * as toplevel and stay-on-top on the application's main widget.
  548.      */
  549.     virtual KMdiToolViewAccessor *addToolWindow( QWidget* pWnd, KDockWidget::DockPosition pos = KDockWidget::DockNone,
  550.                                                  QWidget* pTargetWnd = 0L, int percent = 50, const QString& tabToolTip = 0,
  551.                                                  const QString& tabCaption = 0 );
  552.  
  553.     virtual void deleteToolWindow( QWidget* pWnd );
  554.     virtual void deleteToolWindow( KMdiToolViewAccessor *accessor );
  555.  
  556.     /**
  557.      * Using this method you have to use the setWidget method of the access object, and it is very recommendet, that you use
  558.      * the widgetContainer() method for the parent of your newly created widget
  559.      */
  560.     KMdiToolViewAccessor *createToolWindow();
  561.  
  562.     /**
  563.      * Removes a KMdiChildView from the MDI system and from the main frame`s control.
  564.      * The caller is responsible for deleting the view. If the view is not deleted it will
  565.      * be reparented to 0
  566.      */
  567.     virtual void removeWindowFromMdi( KMdiChildView *pWnd );
  568.  
  569.     /**
  570.      * Removes a KMdiChildView from the MDI system and from the main frame`s control.
  571.      * Note: The view will be deleted!
  572.      */
  573.     virtual void closeWindow( KMdiChildView *pWnd, bool layoutTaskBar = true );
  574.  
  575.     /**
  576.      * Switches the KMdiTaskBar on and off.
  577.      */
  578.     virtual void slot_toggleTaskBar();
  579.  
  580.     /**
  581.      * Makes a main frame controlled undocked KMdiChildView docked.
  582.      * Doesn't work on KMdiChildView which aren't added to the MDI system.
  583.      * Use addWindow() for that.
  584.      */
  585.     virtual void attachWindow( KMdiChildView *pWnd, bool bShow = true, bool bAutomaticResize = false );
  586.  
  587.     /**
  588.      * Makes a docked KMdiChildView undocked.
  589.      * The view window still remains under the main frame's MDI control.
  590.      */
  591.     virtual void detachWindow( KMdiChildView *pWnd, bool bShow = true );
  592.  
  593.     /**
  594.      * Someone wants that the MDI view to be closed. This method sends a KMdiViewCloseEvent to itself
  595.      * to break the function call stack. See also event() .
  596.      */
  597.     virtual void childWindowCloseRequest( KMdiChildView *pWnd );
  598.  
  599.     /**
  600.      * Close all views
  601.      */
  602.     virtual void closeAllViews();
  603.  
  604.     /**
  605.      * Iconfiy all views
  606.      */
  607.     virtual void iconifyAllViews();
  608.  
  609.     /**
  610.      * Closes the view of the active (topchild) window
  611.      */
  612.     virtual void closeActiveView();
  613.  
  614.     /**
  615.      * Undocks all view windows (unix-like)
  616.      */
  617.     virtual void switchToToplevelMode();
  618.     virtual void finishToplevelMode();
  619.  
  620.     /**
  621.      * Docks all view windows (Windows-like)
  622.      */
  623.     virtual void switchToChildframeMode();
  624.     virtual void finishChildframeMode();
  625.  
  626.     /**
  627.      * Docks all view windows (Windows-like)
  628.      */
  629.     virtual void switchToTabPageMode();
  630.     virtual void finishTabPageMode();
  631.  
  632.     /**
  633.      * Docks all view windows. Toolviews use dockcontainers
  634.      */
  635.     virtual void switchToIDEAlMode();
  636.     virtual void finishIDEAlMode( bool full = true );
  637.  
  638.     /**
  639.      * Sets the appearance of the IDEAl mode. See KMultiTabBar styles for the first 3 bits.
  640.      * @deprecated use setToolviewStyle(int flags) instead
  641.      */
  642.     void setIDEAlModeStyle( int flags ) KDE_DEPRECATED;
  643.     //KDE4: Get rid of the above.
  644.     /**
  645.      * Sets the appearance of the toolview tabs.
  646.      * @param flags See KMdi::ToolviewStyle.
  647.      * @since 3.3
  648.      */
  649.     void setToolviewStyle( int flags );
  650.     /**
  651.      * @return if the view taskbar should be shown if there are MDI views
  652.      */
  653.     bool isViewTaskBarOn();
  654.  
  655.     /**
  656.      * Shows the view taskbar. This should be connected with your "View" menu.
  657.      */
  658.     virtual void showViewTaskBar();
  659.  
  660.     /**
  661.      * Hides the view taskbar. This should be connected with your "View" menu.
  662.      */
  663.     virtual void hideViewTaskBar();
  664.  
  665.     /**
  666.      * Update of the window menu contents.
  667.      */
  668.     virtual void fillWindowMenu();
  669.  
  670.     /**
  671.      * Cascades the windows without resizing them.
  672.      */
  673.     virtual void cascadeWindows() { m_pMdi->cascadeWindows(); }
  674.  
  675.     /**
  676.      * Cascades the windows resizing them to the maximum available size.
  677.      */
  678.     virtual void cascadeMaximized() { m_pMdi->cascadeMaximized(); }
  679.  
  680.     /**
  681.      * Maximizes only in vertical direction.
  682.      */
  683.     virtual void expandVertical() { m_pMdi->expandVertical(); }
  684.  
  685.     /**
  686.     * Maximizes only in horizontal direction.
  687.     */
  688.     virtual void expandHorizontal() { m_pMdi->expandHorizontal(); }
  689.  
  690.     /**
  691.      * Tile Pragma
  692.      */
  693.     virtual void tilePragma() { m_pMdi->tilePragma(); }
  694.  
  695.     /**
  696.      * Tile Anodine
  697.      */
  698.     virtual void tileAnodine() { m_pMdi->tileAnodine(); }
  699.  
  700.     /**
  701.      * Tile Vertically
  702.      */
  703.     virtual void tileVertically() { m_pMdi->tileVertically(); }
  704.  
  705.     /**
  706.      * Sets the decoration of the window frame of docked (attached) MDI views
  707.      * @deprecated Will be removed in KDE 4
  708.      */
  709.     virtual void setFrameDecorOfAttachedViews( int frameDecor );
  710.  
  711.     /**
  712.      * If in Childframe mode, we can switch between maximized or restored shown MDI views
  713.      */
  714.     virtual void setEnableMaximizedChildFrmMode( bool bEnable );
  715.  
  716.     /**
  717.      * Activates the next open view
  718.      */
  719.     virtual void activateNextWin();
  720.  
  721.     /**
  722.      * Activates the previous open view
  723.      */
  724.     virtual void activatePrevWin();
  725.  
  726.     /**
  727.      * Activates the view first viewed concerning to the access time.
  728.      */
  729.     virtual void activateFirstWin();
  730.  
  731.     /**
  732.      * Activates the view last viewed concerning to the access time.
  733.      */
  734.     virtual void activateLastWin();
  735.  
  736.     /**
  737.      * Activates the view with the tab page index (TabPage mode only)
  738.      */
  739.     virtual void activateView( int index );
  740.  
  741. private:
  742.     void setupToolViewsForIDEALMode();
  743.     void setupTabbedDocumentViewSpace();
  744.     class KMdiDocumentViewTabWidget * m_documentTabWidget;
  745.  
  746. protected:
  747.  
  748.     virtual void resizeEvent( QResizeEvent * );
  749.  
  750.     /**
  751.      * Creates a new MDI taskbar (showing the MDI views as taskbar entries) and shows it.
  752.      */
  753.     virtual void createTaskBar();
  754.  
  755.     /**
  756.      * Creates the MDI view area and connects some signals and slots with the KMdiMainFrm widget.
  757.      */
  758.     virtual void createMdiManager();
  759.  
  760.     /**
  761.      * prevents fillWindowMenu() from m_pWindowMenu->clear(). You have to care for it by yourself.
  762.      * This is useful if you want to add some actions in your overridden fillWindowMenu() method.
  763.      */
  764.     void blockClearingOfWindowMenu( bool bBlocked ) { m_bClearingOfWindowMenuBlocked = bBlocked; }
  765.  
  766.     void findToolViewsDockedToMain( QPtrList<KDockWidget>* list, KDockWidget::DockPosition dprtmw );
  767.     void dockToolViewsIntoContainers( QPtrList<KDockWidget>& widgetsToReparent, KDockWidget *container );
  768.     QStringList prepareIdealToTabs( KDockWidget* container );
  769.     void idealToolViewsToStandardTabs( QStringList widgetNames, KDockWidget::DockPosition pos, int sizee );
  770.  
  771.     /** Get tabwidget visibility */
  772.     KMdi::TabWidgetVisibility tabWidgetVisibility();
  773.  
  774.     /** Set tabwidget visibility */
  775.     void setTabWidgetVisibility( KMdi::TabWidgetVisibility );
  776.  
  777.     /** Returns the tabwidget used in IDEAl and Tabbed modes. Returns 0 in other modes. */
  778.     class KTabWidget * tabWidget() const;
  779.  
  780.  
  781. protected slots:  // Protected slots
  782.     /**
  783.      * Sets the focus to this MDI view, raises it, activates its taskbar button and updates
  784.      * the system buttons in the main menubar when in maximized (Maximize mode).
  785.      */
  786.     virtual void activateView( KMdiChildView *pWnd );
  787.  
  788.     /**
  789.      * Activates the MDI view (see activateView() ) and popups the taskBar popup menu (see taskBarPopup() ).
  790.      */
  791.     virtual void taskbarButtonRightClicked( KMdiChildView *pWnd );
  792.  
  793.     /**
  794.      * Turns the system buttons for maximize mode (SDI mode) off, and disconnects them
  795.      */
  796.     void switchOffMaximizeModeForMenu( KMdiChildFrm* oldChild );
  797.  
  798.     /**
  799.      * Reconnects the system buttons form maximize mode (SDI mode) with the new child frame
  800.      */
  801.     void updateSysButtonConnections( KMdiChildFrm* oldChild, KMdiChildFrm* newChild );
  802.  
  803.     /**
  804.      * Usually called when the user clicks an MDI view item in the "Window" menu.
  805.      */
  806.     void windowMenuItemActivated( int id );
  807.  
  808.     /**
  809.      * Usually called when the user clicks an MDI view item in the sub-popup menu "Docking" of the "Window" menu.
  810.      */
  811.     void dockMenuItemActivated( int id );
  812.  
  813.     /**
  814.      * Popups the "Window" menu. See also windowPopup() .
  815.      */
  816.     void popupWindowMenu( QPoint p );
  817.  
  818.     /**
  819.      * The timer for main widget moving has elapsed -> send drag end to all concerned views.
  820.      */
  821.     void dragEndTimeOut();
  822.  
  823.     /**
  824.      * internally used to handle click on view close button (TabPage mode, only)
  825.      */
  826.     void closeViewButtonPressed();
  827.  
  828. signals:
  829.     /**
  830.      * Signals the last attached KMdiChildView has been closed
  831.      */
  832.     void lastChildFrmClosed();
  833.  
  834.     /**
  835.      * Signals the last KMdiChildView (that is under MDI control) has been closed
  836.      */
  837.     void lastChildViewClosed();
  838.  
  839.     /**
  840.      * Signals that the Toplevel mode has been left
  841.      */
  842.     void leftTopLevelMode();
  843.  
  844.     /**
  845.      * Signals that a child view has been detached (undocked to desktop)
  846.      */
  847.     void childViewIsDetachedNow( QWidget* );
  848.  
  849.     /** Signals we need to collapse the overlapped containers */
  850.     void collapseOverlapContainers();
  851.  
  852.     /** Signals the MDI mode has been changed */
  853.     void mdiModeHasBeenChangedTo( KMdi::MdiMode );
  854.  
  855.     void viewActivated( KMdiChildView* );
  856.     void viewDeactivated( KMdiChildView* );
  857.  
  858. public slots:
  859.     void prevToolViewInDock();
  860.     void nextToolViewInDock();
  861.  
  862. private slots:
  863.     void setActiveToolDock( KMdiDockContainer* );
  864.     void removeFromActiveDockList( KMdiDockContainer* );
  865.     void slotDocCurrentChanged( QWidget* );
  866.     void verifyToplevelHeight();
  867. #define protected public
  868. signals:
  869. #undef protected
  870.  
  871.     void toggleTop();
  872.     void toggleLeft();
  873.     void toggleRight();
  874.     void toggleBottom();
  875. };
  876.  
  877. #endif //_KMDIMAINFRM_H_
  878.  
  879. // kate: space-indent off; tab-width 4; replace-tabs off; indent-mode csands;
  880.